<template>
  <div class="hello-world">
    <h2>{{ message }}</h2>
    <button @click="greet" class="greet-btn">打招呼</button>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// 定义属性
const props = defineProps({
  message: {
    type: String,
    default: '你好，Vue3!'
  }
})

// 定义事件
const emit = defineEmits(['greet'])

// 方法
const greet = () => {
  console.log('Hello from HelloWorld component!')
  emit('greet')
}
</script>

<style scoped>
.hello-world {
  text-align: center;
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: white;
}

h2 {
  color: #333;
  margin-bottom: 1rem;
}

.greet-btn {
  background-color: #42b983;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s;
}

.greet-btn:hover {
  background-color: #3aa876;
}
</style>